package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SysCompanyReportReason;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCompanyCase;
import com.ruoyi.system.service.ISysCompanyCaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业典型案例Controller
 * 
 * @author ruoyi
 * @date 2023-09-09
 */
@Api(tags = "企业典型案例")
@RestController
@RequestMapping("/system/case")
public class SysCompanyCaseController extends BaseController
{
    @Autowired
    private ISysCompanyCaseService sysCompanyCaseService;

    /**
     * 查询企业典型案例列表（分页）
     */
    @ApiOperation(value = "查询企业典型案例列表（分页）")
  //  @PreAuthorize("@ss.hasPermi('system:case:list')")
    @GetMapping("/page")
    public TableDataInfo page(SysCompanyCase sysCompanyCase)
    {
        startPage();
        List<SysCompanyCase> list = sysCompanyCaseService.selectSysCompanyCaseList(sysCompanyCase);
        return getDataTable(list);
    }


    /**
     * 查询企业典型案例列表
     */
    //  @PreAuthorize("@ss.hasPermi('system:reason:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询企业典型案例列表")
    public AjaxResult list(SysCompanyCase sysCompanyCase)
    {

        List<SysCompanyCase> list = sysCompanyCaseService.selectSysCompanyCaseList(sysCompanyCase);
        return AjaxResult.success(list);
    }

    /**
     * 导出企业典型案例列表
     */
    @PreAuthorize("@ss.hasPermi('system:case:export')")
    @Log(title = "企业典型案例", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCompanyCase sysCompanyCase)
    {
        List<SysCompanyCase> list = sysCompanyCaseService.selectSysCompanyCaseList(sysCompanyCase);
        ExcelUtil<SysCompanyCase> util = new ExcelUtil<SysCompanyCase>(SysCompanyCase.class);
        util.exportExcel(response, list, "企业典型案例数据");
    }

    /**
     * 获取企业典型案例详细信息
     */
    @ApiOperation(value = "获取企业典型案例详细信息")
 //   @PreAuthorize("@ss.hasPermi('system:case:query')")
    @GetMapping(value = "/{caseId}")
    public AjaxResult getInfo(@PathVariable("caseId") Long caseId)
    {
        return AjaxResult.success(sysCompanyCaseService.selectSysCompanyCaseByCaseId(caseId));
    }

    /**
     * 新增企业典型案例
     */
    @ApiOperation(value = "新增企业典型案例")
  //  @PreAuthorize("@ss.hasPermi('system:case:add')")
    @Log(title = "企业典型案例", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCompanyCase sysCompanyCase)
    {
        return toAjax(sysCompanyCaseService.insertSysCompanyCase(sysCompanyCase));
    }

    /**
     * 修改企业典型案例
     */
    @ApiOperation(value = "修改企业典型案例")
  //  @PreAuthorize("@ss.hasPermi('system:case:edit')")
    @Log(title = "企业典型案例", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCompanyCase sysCompanyCase)
    {
        return toAjax(sysCompanyCaseService.updateSysCompanyCase(sysCompanyCase));
    }

    /**
     * 删除企业典型案例
     */
    @ApiOperation(value = "删除企业典型案例")
  //  @PreAuthorize("@ss.hasPermi('system:case:remove')")
    @Log(title = "企业典型案例", businessType = BusinessType.DELETE)
	@DeleteMapping("/{caseIds}")
    public AjaxResult remove(@PathVariable Long[] caseIds)
    {
        return toAjax(sysCompanyCaseService.deleteSysCompanyCaseByCaseIds(caseIds));
    }
}
